/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ujf.sharepas.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;

import edu.ujf.sharepas.impl.Constante.Right;


/**
 *
 * @author yaiba
 */
public class Category implements Serializable {

    /**
	 * 
	 */
	private static final long serialVersionUID = 7094652572555196661L;
	private List<Category> subCategory ;
   

	private List<ShareFile> listShareFile;
	private String name = null;
	private int type ;
	
    public Category(String name, int type){
    	this.setName(name);
    	this.type = type ;
    	subCategory = new ArrayList<Category>(); 
    	listShareFile = new ArrayList<ShareFile>();
    }
    
    public ShareFile addShareFile(String file, int r){
    	Right right = null;
    	if( r == Constante.Right.READ.toInt() ){
    		right = Right.READ;
    	}else if( r == Constante.Right.WRITE.toInt() ){
    		right = Right.WRITE;
    	}
    	ShareFile f = new ShareFile(file,right);
    	this.listShareFile.add(f);
    	return f;
    }


	public void setSubCategory(List<Category> subCategory) {
		this.subCategory = subCategory;
	}

	public List<Category> getSubCategory() {
		return subCategory;
	}
	
    public List<ShareFile> getListShareFile() {
		return listShareFile;
	}

 
	public boolean hasSubCategory(){
		return subCategory.size() == 0 ? false : true ;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void addShareFile(ShareFile f) {
		this.listShareFile.add(f);
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getType() {
		return type;
	}

    
}
